<?php
/**
 * @file
 */


/**
 * Implements of hook_nodejschat_plugin_info()
 */
function nodejschat_nodejschat_plugin_info() {
  $plugins['message_style'] = array(
    'name' => 'message_style',
    'title' => t('Style'),
    'settings' => array(),
  );
  $plugins['sound'] = array(
    'name' => 'sound',
    'title' => t('Sound'),
    'settings' => array(),
  );
  return $plugins;
}

/**
 * Implements of hook_boardchat_plugin_form()
 */
function nodejschat_nodejschat_plugin_form($form, $form_state, $nodejschat, $plugin, $element = array()) {
  $plugin_name = $plugin['name'];
  switch ($plugin_name) {
    case 'message_style':
      $element['font_weight'] = array(
        '#type' => 'button',
        '#value' => t('B'),
      );
      $element['font_style'] = array(
        '#type' => 'button',
        '#value' => t('I'),
      );
      $element['text_decoration'] = array(
        '#type' => 'button',
        '#value' => t('U')
      );

      $font_options = array(
        '' => t('Choose Font'), 'Arial' => t('Arial'), 'Arial Black' => t('Arial Black'), 'Book Antiqua' => t('Book Antiqua'), 'Century Gothic' => t('Century Gothic'), 'Comic Sans MS' => t('Comic Sans MS'), 'Courier New' => t('Courier New'), 'Impact' => t('Impact'), 'Tahoma' => t('Tahoma'), 'Times New Roman' => t('Times New Roman'), 'Trebuchet MS' => t('Trebuchet MS'), 'Verdana' => t('Verdana')
      );
      $color_options = array(
        '' => t('Choose Color'), 'Gold' => t('Gold'), 'Khaki' => t('Khaki'), 'Orange' => t('Orange'), 'LightPink' => t('LightPink'), 'Salmon' => t('Salmon'), 'DarkGreen' => t('DarkGreen'), 'DarkCyan' => t('DarkCyan'), 'LightSeaGreen' => t('LightSeaGreen'), 'LawnGreen' => t('LawnGreen'), 'MediumSeaGreen' => t('MediumSeaGreen'), 'BlueViolet' => t('BlueViolet'), 'Cyan' => t('Cyan'), 'Blue' => t('Blue'), 'DodgerBlue' => t('DodgerBlue'), 'LightSkyBlue' => t('LightSkyBlue'), 'White' => t('White'), 'DimGray' => t('DimGray'), 'DarkGray' => t('DarkGray'), 'Black' => t('Black')
      );

      $element['font_family'] = array(
        '#type' => 'select',
        //'#title' => t('Font'),
        '#default_value' => 0,
        '#options' => $font_options
      );

      $element['color'] = array(
        '#type' => 'select',
        //'#title' => t('Color'),
        '#default_value' => 0,
        '#options' => $color_options
      );
      drupal_add_js(drupal_get_path('module', 'nodejschat_plugin') . '/nodejschat_plugin.js', array('weight' => 11));
      break;
    case 'sound':
      drupal_add_js(drupal_get_path('module', 'nodejschat_plugin') . '/nodejschat_sounds.js', array('weight' => 11));
      $ogg = file_create_url(drupal_get_path('module', 'nodejschat_plugin') . '/sounds/notify.ogg');
      $mp3 = file_create_url(drupal_get_path('module', 'nodejschat_plugin') . '/sounds/notify.mp3');
      $output = '<audio id="notification_sound" style="dispaly:none" preload="auto">
        <source src="' . $ogg . '" type="audio/ogg" />
        <source src="' . $mp3 . '" type="audio/mp3" />
              </audio>';
      $output .= '<span id="nodejschat-sound-on-off-' . $nodejschat->get('cid') . '">
                <input class="nodejschat-sound-on-off-button" value="Turn Sound Off" type="submit" class="form-submit">
              </span>';
      $element['sounds'] = array(
        '#markup' => $output,
      );
      drupal_add_js(array('nodejschat' => array(
        'sound' => array('on' => TRUE, 'cid' => $nodejschat->get('cid')))), 'setting');
      break;
  }
  return $element;
}
/**
 * Implements of hook_nodejschat_plugins()
 */
function nodejschat_nodejschat_plugin($nodejschat, $plugin, $data = array(), $options) {
  if ($plugin['name'] == 'message_style') {
    dsm($data);
    dsm($nodejschat);
  }
}